package com.dapangdong.testdemo.controller.test;

import cn.hutool.core.util.NumberUtil;
import com.dapangdong.testdemo.annotation.Operation;
import io.swagger.annotations.Api;
import lombok.Builder;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Objects;
import java.util.UUID;

/**
 * <p>
 *
 * </p>
 *
 * @author : yhd
 * @program: gulimall
 * @since : 2023-04-10 09:55
 */
@Api(tags = "equals测试API")
@RestController
@RequestMapping(value = "/equals")
public class EqualsController {

    @Operation
    @PostMapping(value = "/user")
    public String getLogin(@RequestBody Map<String,Object> map) {
        return "User Id : 大头\nRole Id : 超级管理员"+map.toString();
    }

    @Operation
    @GetMapping(value = "/login")
    public String login(@RequestParam(required = false) Integer a,@RequestParam(required = false) Integer b) {
        return "User Id : 大头\nRole Id : 超级管理员"+a+b;
    }




    public static class ClassA {
        private String name;
        private Integer age;


        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            ClassA that = (ClassA) o;
            return Objects.equals(name,that.name)&&
                    age.equals(that.age);
        }

        @Override
        public int hashCode() {
            return Objects.hash(name, age);
        }

        @Builder
        public ClassA(String name,int age){
            this.name = name;
            this.age = age;
        }
    }

    public static void main(String[] args) {
        UUID uuid = UUID.randomUUID();
        System.out.println(uuid);
        System.out.println(NumberUtil.isNumber("121.032"));

        String s1 = "小";
        String s2 = "小白";

        ClassA class1 = ClassA.builder().name(s1).age(10).build();
        ClassA class2 = ClassA.builder().name(s2).age(10).build();

        System.out.println(class1.equals(class2));



    }



}
